using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace 纺织贸易管理系统
{
    public static class StockTableService
    {
        public static List<StockTable> GetStockTableDataTable(Expression<Func<StockTable, bool>> func)
        {
            return Connect.CreatConnect().Query(func);
        }
        public static List<StockTable> GetStockTablelst(Expression<Func<StockTable,bool>> func)
         {
            return  Connect.dbcontext.Queryable<StockTable>().Where (func).ToList ();
         }
        public static List<StockTable> GetStockTablelst(string UpdteString)
        {
            return Connect.dbcontext .Ado.SqlQuery<StockTable>(UpdteString );
        }
        public static List<StockTable> GetStockTablelst()
        {
            return Connect.dbcontext.Queryable<StockTable>().ToList ();
        }
        public static StockTable GetOneStockTable(Expression<Func<StockTable, bool>> func)
         {
            var stock=  Connect.dbcontext.Queryable<StockTable>().First(func);
            return stock ?? new StockTable();
         }
        public static void InsertStockTablelst(List<StockTable> StockTableObjs)
         {   
              Connect.dbcontext.Insertable(StockTableObjs).ExecuteCommand ();
         }
        public static void InsertStockTable(StockTable StockTableObj)
         {
            Connect.dbcontext.Insertable<StockTable>(StockTableObj).ExecuteCommand();
        
         }
        public static void UpdateStockTable(StockTable stock)
        {
            Connect.dbcontext.Updateable(stock).ExecuteCommand ();
        }
        public static void UpdateStockTable(Expression<Func<StockTable, bool>> UpdateFunc, Expression<Func<StockTable, bool>> func)
        {
           
            Connect.CreatConnect().Update<StockTable>(UpdateFunc , func);
        }
        public static void UpdateStockTable(StockTable StockTableObj, Expression<Func<StockTable, bool>> func)
         {
              Connect.CreatConnect().Update<StockTable>(StockTableObj,func);
         }
        public static void UpdateStockTable(string UpdateString , Expression<Func<StockTable, bool>> func)
        {
            Connect.CreatConnect().Update<StockTable>(UpdateString , func);
        }
        public static void DeleteStockTable(Expression<Func<StockTable, bool>> func)
         {
              Connect.dbcontext.Deleteable<StockTable>().Where (func).ExecuteCommand ();
         }
        public static List<StockInfoTable> GetStockInfoTables()
        {
          return  Connect.CreatConnect().Query<StockInfoTable>();
        }
        public static List<StockInfoTable> GetStockInfoTables(Expression<Func<StockInfoTable, bool>> func)
        {
            return Connect.CreatConnect().Query<StockInfoTable>(func);
        }
    }
}
